<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <include file="./Public/Admin/header.html" />
    <style>
        .form-horizontal .control-group {
            margin-bottom: 10px;
        }

        .input-medium {
            width: 330px;
        }

        #keyword {
            width: 323px;
        }
        .span2{margin-bottom: 10px;}
        .span12{overflow: hidden;}
        .span12 .span5{float:left;width: 30%;}
    </style>
</head>
<body>
<div id="main">
    <div class="container-fluid">

        <div class="row-fluid">
            <div class="span12">
                <div class="box">
                    <div class="box-title">
                        <div class="span4">
                            <h3><i class="icon-edit"></i>订单列表</h3>
                        </div>
                    </div>

                    <div class="box-content">

                        <div class="row-fluid">
                            <div class="span10 control-group">
                                <div class="span2" style="width: 100%;">
                                <div class="span2" style="width: 100%;">
                                    <a class="btn" href="javascript:location.reload()"><i class="icon-refresh"></i>刷新</a>
                                </div>
                                <div class="btn-group pull-right clearfix " style="float: left;">
                                    <form action="{:U('index')}" method="get" class="form-horizontal" style="margin: 0px;">
                                           <select name="courses_id">
                                               <volist name="courses" id="val">
                                                 <option value="{$val['id']}">{$val['name']}</option>
                                               </volist>
                                           </select>
                                        <button class="btn" id="btn_search">查询</button>
                                    </form>
                                </div>
                            </div>
                        </div>
                        <div class="row-fluid dataTables_wrapper">
                            <table id="listTable" class="table table-bordered table-hover  dataTable">
                                <thead>
                                <tr>
                                    <th> 订单id </th>
                                    <th >课程名称</th>
                                    <th>用户名称</th>
                                    <th>总价</th>
                                <th>订单状态</th>
                                <th>支付时间</th>

                                </tr>
                                </thead>
                                <tbody>
                                <foreach name="list" item="v">
                                    <tr>
                                        <td ><?php echo $v['id']?></td>
                                        <td ><?php echo M('courses')->where(array('id'=>$v['courses_id']))->getField('name');?></td>
                                        <td ><?php echo M('wx_users')->where(array('id'=>$v['user_id']))->getField('nickname');?></td>
                                        <td ><?php echo $v['price']?></td>
                                        <td >
                                            <?php if($v['status']==2):?>
                                                 已支付
                                            <?php else:?>
                                            未支付


                                            <?php endif;?>
                                        <td >{$v.time_end}</td>

                                    </tr>

                                </foreach>
                                <if condition="($count eq 0) ">
                                    <tr><td align="center" colspan="11">暂无记录</td></tr>
                                </if>
                                </tbody>
                            </table>
                            <div class="row-fluid">
                                <div class="span4">
                                    <div class="dataTables_info">
                                        <if condition="($count gt 0) ">
                                            共{$count}条记录，当前第{$nowPage}/{$totalPages}页
                                        </if>
                                    </div>
                                </div>
                                <div class="span8">
                                    {$page}
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

        </div>
    </div>
</div>
<script type="text/javascript">
    $(function(){
        //审核
        $("a[attr^='deltext_info_']").click(function(){
            var tmp = $(this).attr('attr').split('_');
            var status = tmp[3];
            id =tmp[2];
            delText(id,status);
        });
        $("a[attr^='deltext_info1_']").click(function(){
            var tmp = $(this).attr('attr').split('_');
            var status = tmp[3];
            id =tmp[2];
            delText(id,status);
        });

    });
    //审核
    function delText(id,status){
        if(status == 1){
            var str = '您确定审核通过吗?'
        }else if(status == 2){
            var str = '您确定审核不通过吗?'
        }
        G.ui.tips.confirm_flag(str,function(){
            $.post("{:U('reviewed')}", {id:id,status:status},function(data){
                if (data.errno ==0)
                {
                    location.reload();
                } else {

                    G.ui.tips.err(data.error);
                }
            },'json');
        });
    }
</script>
</body>
</html>